﻿using UnityEngine;
using System.Collections;

public class Player2Controller : MonoBehaviour {
	
	public bool moveLeft2 = false;
	public bool moveRight2 = false;
	public bool moveUp2 = false;
	public bool moveDown2 = false;
	public bool shootBullet2 = false;
	
	public float playerMaxSpeed = 5f;
	//	bool facingRight = false;
	//	bool facingLeft = false;
	//	bool facingUp = true;
	//	bool facingDown = false;
	public Transform myPlayer2;
	
	public float playerCurrentBullet = 100;
	
	public GameObject shot2;
	public Transform shotSpawn2;
	
	public Vector3 playerScale2;
	
	public float playerMaxHealth = 3;
	public float playerCurrentHealth = 3;
	
	public SpriteRenderer playerImage2;
	
	private GameObject Player2;
	
	private float move = 0;
	
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if (shootBullet2) {
			GameObject myBullet1 = Instantiate (shot2, shotSpawn2.position, shotSpawn2.rotation) as GameObject;
			myBullet1.transform.localScale = myPlayer2.localScale;
		}
		if (playerMaxHealth == 0) {
			Application.LoadLevel ("GameOve1"); 
		}
	}
	
	void FixedUpdate () {
		if(moveLeft2){
			transform.Translate (0.05f,0,0);
		}
		else if(moveRight2)
			transform.Translate(-0.05f,0,0);
		else if(moveUp2)
			transform.Translate(0,0.05f,0);
		else if(moveDown2)
			transform.Translate(0,-0.05f,0);
	}

}